#!/usr/bin/env python3
"""
创建入场登记记录表
"""

import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from app import create_app, db
from app.models.checkin_record import CheckinRecord

def create_checkin_records_table():
    """创建入场登记记录表"""
    app = create_app()
    
    with app.app_context():
        try:
            # 创建表
            db.create_all()
            print("✅ 入场登记记录表创建成功")
            
            # 检查表是否存在
            result = db.engine.execute("SHOW TABLES LIKE 'checkin_records'")
            if result.fetchone():
                print("✅ checkin_records 表已存在")
                
                # 显示表结构
                result = db.engine.execute("DESCRIBE checkin_records")
                print("\n📋 表结构:")
                for row in result:
                    print(f"  {row[0]}: {row[1]} {row[2]}")
            else:
                print("❌ checkin_records 表创建失败")
                
        except Exception as e:
            print(f"❌ 创建表时出错: {e}")

if __name__ == '__main__':
    create_checkin_records_table() 